package com.movie.ticket.sale.authorassembly.dao;

import com.movie.ticket.sale.moviecommon.model.TCinemaContract;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Ticket
 * @since 2020-12-08
 */
public interface TCinemaContractMapper extends BaseMapper<TCinemaContract> {

    @Insert("insert into t_cinema_contract(cinema_id,number,version,create_time,state,count,path) values(#{cinemaId},#{number},#{version},#{createTime},0,0,#{path})")
    void registerAddNewContract(TCinemaContract cinemaContract);

    @Select("select * from t_cinema_contract where cinema_id=#{id}")
    TCinemaContract findContractByCinemaId(int id);

    @Update("update t_cinema_contract set count=count+1,state=1,create_time=#{date1} where cinema_id=#{id}")
    void addContractChangeTimes(@Param("id") int id, @Param("date1") LocalDateTime date);

    @Update("update t_cinema_contract set state=#{state} where id=#{id}")
    void changeState(@Param("id")Integer id, @Param("state")int i);

    @Update("update t_cinema_contract set sign_img=#{url} where id=#{id}")
    void addSignPathToContract(@Param("id")Integer id, @Param("url")String url);
}
